package com.zhuotiao.crm;

import com.github.pagehelper.PageHelper;
import com.spring4all.swagger.EnableSwagger2Doc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import tk.mybatis.spring.annotation.MapperScan;

import java.util.Properties;

/**
 * Created by dongyang.yu on 18-8-27.
 */
@SpringBootApplication(scanBasePackages = {"com.zhuotiao.crm", "com.pikachu.web"})
@EnableSwagger2Doc
@MapperScan(basePackages = {"com.zhuotiao.crm.mapper"})
@EnableAsync
@EnableScheduling
public class CrmApplicationBootstrap {

    /**
     * 分页插件
     * @return
     */
    @Bean
    public PageHelper pageHelper() {
        PageHelper pageHelper = new PageHelper();
        Properties p = new Properties();
        p.setProperty("helper-dialect", "mysql");
        p.setProperty("offsetAsPageNum", "true");
        p.setProperty("rowBoundsWithCount", "true");
        p.setProperty("reasonable", "false");
        p.setProperty("returnPageInfo", "check");
        p.setProperty("params", "count=countSql");
        pageHelper.setProperties(p);
        return pageHelper;
    }

    public static void main(String[] args) {
        SpringApplication.run(CrmApplicationBootstrap.class, args);
    }
}
